package org.cyclone.order.rcp.intro;

import org.cyclone.order.ui.menu.CreateConnectionAction;
import org.cyclone.order.ui.menu.DisconnectServerAction;
import org.cyclone.order.ui.menu.ShowViewAction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

/**
 * yzhang class global comment. Detailled comment <br/>
 * 
 * $Id: talend.epf 1 2006-09-29 17:06:40Z nrousseau $
 * 
 */
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchWindow window;

    private IActionBarConfigurer configurer;

    /**
     * yzhang ApplicationActionBarAdvisor constructor comment.
     * 
     * @param configurer
     */
    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
        this.configurer = configurer;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.application.ActionBarAdvisor#makeActions(org.eclipse.ui.IWorkbenchWindow)
     */
    @Override
    protected void makeActions(IWorkbenchWindow window) {
        this.window = window;

    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.application.ActionBarAdvisor#fillMenuBar(org.eclipse.jface.action.IMenuManager)
     */
    @Override
    protected void fillMenuBar(IMenuManager menuBar) {
        MenuManager fileMenuManager = new MenuManager("Operation");
        MenuManager windowMenuManager = new MenuManager("Window");
        MenuManager helpMenuManager = new MenuManager("Help");

        menuBar.add(fileMenuManager);
        menuBar.add(windowMenuManager);
        menuBar.add(helpMenuManager);

        // operation menu.
        IAction connectServer = new CreateConnectionAction();
        IAction disConnectServer = new DisconnectServerAction();
        IAction quitAction = ActionFactory.QUIT.create(window);

        fileMenuManager.add(connectServer);
        fileMenuManager.add(disConnectServer);
        fileMenuManager.add(new Separator());
        fileMenuManager.add(quitAction);

        // window menu.

        IAction preferenceAction = ActionFactory.PREFERENCES.create(window);
        IAction showViewAction = new ShowViewAction();

        windowMenuManager.add(showViewAction);
        windowMenuManager.add(preferenceAction);

        // help menu.
        IAction aboutAction = ActionFactory.ABOUT.create(window);

        helpMenuManager.add(aboutAction);

    }
}
